<template>
  <div id="shop-cart">
    <nav-bar class="nav-bar">
      <template v-slot:center>
        <div>购物车({{cartLength}})</div>
      </template>
    </nav-bar>
    <cart-list></cart-list>
    <cart-bottom-bar></cart-bottom-bar>
  </div>
</template>

<script>
import NavBar from "components/common/navbar/NavBar";
import CartList from "./childComps/CartList";
import CartBottomBar from "./childComps/CartBottomBar";

//导入vuex中的辅助函数
import {mapGetters} from 'vuex'
export default {
  name: "ShopCart",
  components: {
    NavBar,
    CartList,
    CartBottomBar
  },
  computed: {
    // cartLength(){
    //   return this.$store.state.cartList.length
    // }
    ...mapGetters({
      cartLength: 'cartLength',
    })
  }
}
</script>

<style scoped>
  #shop-cart{
    height: 100vh;
  }
  .nav-bar{
    background-color: var(--color-tint);
    color: #fff;
    font-weight: 500;
  }
</style>
